package com.dpj.entity;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class BigCat {

	private String AcCategoryID;
	private String CateGoryName;
	public String getAcCategoryID() {
		return AcCategoryID;
	}
	public void setAcCategoryID(String acCategoryID) {
		AcCategoryID = acCategoryID;
	}
	public String getCateGoryName() {
		return CateGoryName;
	}
	public void setCateGoryName(String cateGoryName) {
		CateGoryName = cateGoryName;
	}
	
	
	public static List<BigCat> getBigCatList(String json) {
		List<BigCat> list = new ArrayList<BigCat>();
		try {
			JSONArray ja = new JSONArray(json);
			if (ja != null && ja.length() > 0) {
				for (int i = 0; i < ja.length(); i++) {
					JSONObject ja_jo = ja.optJSONObject(i);
					JSONObject jo_app = ja_jo.optJSONObject("APP");
					JSONObject jo_aos = jo_app.optJSONObject("ArrayOfAcCategory");
					if(jo_aos != null) {
						JSONArray ja_jo_store = jo_aos.optJSONArray("AcCategory");
						if (ja_jo_store != null && ja_jo_store.length() > 0) {
							for (int j = 0; j < ja_jo_store.length(); j++) {
								JSONObject jo_store = ja_jo_store.optJSONObject(j);
								BigCat bCat = new BigCat();
								bCat.setAcCategoryID(jo_store.optString("AcCategoryID"));
								bCat.setCateGoryName(jo_store.optString("CateGoryName"));
								list.add(bCat);
							}
						} else {
							JSONObject jo_one = jo_aos.optJSONObject("AcCategory");
							BigCat bCat_one = new BigCat();
							bCat_one.setAcCategoryID(jo_one.optString("AcCategoryID"));
							bCat_one.setCateGoryName(jo_one.optString("CateGoryName"));
							list.add(bCat_one);
						}
					}
				}
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return list;
	}
	@Override
	public String toString() {
		return CateGoryName;
	}
	
	
}
